#include "DeviceNormal.h"



DeviceNormal::DeviceNormal(int size): DeviceFloat3(size), seg(480, 640) {
	cudaMalloc(&segmentationMap, sizeof(int) * num);	
	cudaMalloc(&localPlanarStructure, sizeof(bool) * num);
	//cv::namedWindow("segm");
}

DeviceNormal::~DeviceNormal(){
	cudaFree(segmentationMap);
	cudaFree(localPlanarStructure);
}

bool* DeviceNormal::getSegmentationResult(){
	bool* out = new bool[640 * 480];
	cudaMemcpy(out, localPlanarStructure, sizeof(bool) * 640 * 480, cudaMemcpyDeviceToHost);

	for(int i = 0; i < 480; i++){
		for(int j = 0; j < 640; j++){
			seg.at<unsigned char>(cv::Point2d(j, i)) = out[j + i * 640] ? 255 : 0;
		}
	}

	cv::imshow("segm", seg);
	cv::waitKey(1);

	delete[] out;
	return localPlanarStructure;
}

